package com.cmy.service.role;

import com.cmy.dao.BaseDao;
import com.cmy.dao.role.RoleDao;
import com.cmy.dao.role.RoleDaoImp1;
import com.cmy.pojo.Role;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class RoleServiceImp1 implements RoleService{

    //引入Dao
        //设置私有属性roledao
    private RoleDao roleDao;
        //通过构造方法引入Dao
    public RoleServiceImp1() {
        roleDao = new RoleDaoImp1();
    }


    public List<Role> getRoleList(){
        Connection connection = null;
        List<Role> roleList = null;
        try {
            connection = BaseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            BaseDao.release(connection,null,null);
        }
        return roleList;
    }
//    @Test
//    public void test(){
//        List<Role> roleList = getRoleList();
//        for (Role role : roleList) {
//            System.out.println(role.getRoleName());
//        }
//    }
}

    